package com.richard.room.operator.api.type;

/**
 * @author: Richard
 * @createDate: 2023/8/8 16:23
 * @version: 1.0
 * @description: 表达式类型
 */
public enum ExpressionType {

    equal("= ?","= %s","? = %s"),//等于
    notEqual("!= ?","!= %s","? != %s"),//不等于
    less("< ?","< %s","? < %s"),//小于
    lessOrEqual("<= ?","<= %s","? <= %s"),//小于等于
    greater("> ?", "> %s","? > %s"),//大于
    greaterOrEqual(">= ?",">= %s","? >= %s"),//大于等于
    between("between ? and ?","between %s and %s",null),//两者之间
    in("in","in(%s)",null),//包含
    like("like ?","like %s","? like %s"),//自定义匹配规则匹配
    contains("like '%' || ? || '%'","like '%%' || %s || '%%'","? like '%%' || %s || '%%'"),//完全模糊匹配
    startWith("like ? || '%'","like %s || '%%'","? like %s || '%%'"),//以什么开头
    endWith("like '%' || ?","like '%%' || %s","? like '%%' || %s"),//以什么结尾
    regExp("regexp ?","regexp %s","? regexp %s"),//检查一个字符串是否与指定的正则表达式模式匹配
    isNull("is null","is null",null),//为null
    notNull("is not null","is not null",null),//不为null
    exists("exists","exists",null),//判断记录是否存在
    ;

    /**对应sqlite表达式*/
    private final String exp;

    /**格式化占位方式表达式字符串*/
    private final String format;

    /**表达式左右条件反转格式，为空代表不支持反转*/
    private final String reverseFormat;

    ExpressionType(String exp, String format,String reverseFormat){
        this.exp = exp;
        this.format = format;
        this.reverseFormat = reverseFormat;
    }

    public String getExp() {
        return exp;
    }

    public String getFormat() {
        return format;
    }

    public String getReverseFormat() {
        return reverseFormat;
    }
}
